package exceptions;

public class Test2 {
	public static void main(String args[]) throws MyException {
		int value = -1;
		m(value);
	}

	public static void m(int value) throws MyException {
		try {
			if (value < 0)
				throw new MyException();

		}

		finally {
			System.out.println("Finally executed ...");
			System.out.println("Resources clean-up done ...");
		}
	}
}

/*
 * when an exception occurs ,first finally block is executed and then the
 * exception is propagated.
 * 
 * If we dont provide catch block ,then finally must be present and throws
 * declaration must be present(for checked exceptions)
 * 
 * 'finally' blocks are always executed unless ,the executing thread stops
 * System.exit() is invoked int try block etc.
 * 
 * Read exception suppression
 */